package cn.buk.tms.comparator;


import cn.buk.tms.entity.bill.BillInfo;
import java.util.Comparator;

import static cn.buk.tms.common.constant.TmsOrderConstant.*;

public class BillSortComparator implements Comparator<BillInfo> {

  @Override
  public int compare(BillInfo o1, BillInfo o2) {
    final int billType1 = getBillType(o1.getBillType());
    final int billType2 = getBillType(o2.getBillType());

    if (billType1 > billType2) {
      return 1;
    } else if (billType1 < billType2) {
      return -1;
    }

    return 0;
  }

  private int getBillType(String billType) {
    if (BILL_TYPE_FLIGHT.equalsIgnoreCase(billType)) {
      return 1;
    } else if (BILL_TYPE_FLIGHT_REFUND.equalsIgnoreCase(billType)) {
      return 2;
    } else if (BILL_TYPE_FLIGHT_CHANGE.equalsIgnoreCase(billType)) {
      return 3;
    } else if (BILL_TYPE_HOTEL.equalsIgnoreCase(billType)) {
      return 4;
    } else if (BILL_TYPE_TRAIN.equalsIgnoreCase(billType)) {
      return 5;
    } else if (BILL_TYPE_VAS.equalsIgnoreCase(billType)) {
      return 6;
    } else {
      return 99;
    }
  }
}
